<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * @author Thomas Brandstätter <tb.essentialmind.com>
    * @version n/a
    * @copyright essentialmind.com 2010
    *
    *********************************************************/

    /***
    * class ajaxChangeNodeOrderPos
    ****
    * This class will change the order_pos of given node
    ****
    * @package ajax
    * @author Thomas Brandstätter <tb.essentialmind.com>
    * @version n/a
    * @copyright essentialmind.com 2010
    ***/
    class ajaxChangeNodeOrderPos extends ajaxAction{

        function process(){
			try{
                // prepare variables
                $position   = (int)$_REQUEST['position'];
                $node_id    = (int)$_REQUEST['node_id'];
                $node_type  = $_REQUEST['node_type'];
                
                //update order_pos
				if ($GLOBALS['_CONFIG']['enable_order_position']) {
					$this->db->Execute("UPDATE structure SET order_pos = " . $position . " WHERE id = " . $node_id);
				}
                
                // data to return 
                $this->r->position = $position;
                $this->r->node_id = $node_id;
                $this->r->node_type = $node_type;
            //something went wrong
            }catch(exception $e){
                //log error
                $this->log->recordError($e->getMessage());

                //do nothing
            }
        }
    }
?>